import request from '@/config/axios'

// IM会话 VO
export interface MemberConversationVO {
  id: number // 编号
  groupId: number // 分组ID
  groupType: number // 分组类型
  groupLogo: string // 分组封面
  byUserId: number // 会话用户ID
  userId: number // 会话所属用户ID
  lastMessageTime: Date // 最后聊天时间
  lastMessageContent: string // 最后聊天内容
  lastMessageContentType: number // 最后发送的消息类型
  lastMessageReadStatus: string // 最后发送的消息是否已读
  pinned: string // 置顶
  unreadMessageCount: number // 未读消息数
}

// IM会话 API
export const MemberConversationApi = {
  // 查询IM会话分页
  getMemberConversationPage: async (params: any) => {
    return await request.get({ url: `/im/member-conversation/page`, params })
  },

  // 查询IM会话详情
  getMemberConversation: async (id: number) => {
    return await request.get({ url: `/im/member-conversation/get?id=` + id })
  },

  // 新增IM会话
  createMemberConversation: async (data: MemberConversationVO) => {
    return await request.post({ url: `/im/member-conversation/create`, data })
  },

  // 修改IM会话
  updateMemberConversation: async (data: MemberConversationVO) => {
    return await request.put({ url: `/im/member-conversation/update`, data })
  },

  // 删除IM会话
  deleteMemberConversation: async (id: number) => {
    return await request.delete({ url: `/im/member-conversation/delete?id=` + id })
  },

  // 导出IM会话 Excel
  exportMemberConversation: async (params) => {
    return await request.download({ url: `/im/member-conversation/export-excel`, params })
  },
}